package com.huang.PC;

import java.util.List;
import java.util.concurrent.TimeUnit;

public class C implements Runnable{
    private String name;
    List<Object> contain;

    public C(String name, List<Object> contain) {
        this.name = name;
        this.contain = contain;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            synchronized (contain) {
                while (contain.size() == 0) {
                    try {

                        contain.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                contain.remove(0);
                System.out.println(name + "消费了。。。");

                contain.notifyAll();
            }
        }
        }




}
